package com.zzptc.lhl.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.TextView;

import com.zzptc.lhl.myapplication.entity.Carinfo;
import com.zzptc.lhl.myapplication.entity.QicheGuzhang;
import com.zzptc.lhl.myapplication.service.CarlistService;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class MainActivity extends AppCompatActivity {
    TextView textView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        textView=findViewById(R.id.tv);
        getCarInfo();
        getQicheGuzhangInfo();
    }

    private void getQicheGuzhangInfo() {
        Retrofit retrofit=new Retrofit.Builder()
                .baseUrl("http://apis.juhe.cn/obdcode")
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        CarlistService carlistService=retrofit.create(CarlistService.class);
        


    }

    private void getCarInfo() {
        Retrofit retrofit=new Retrofit.Builder()
                .baseUrl("http://www.hnzzsgz.cn:5001/")
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        CarlistService carlistService=retrofit.create(CarlistService.class);
        Call<Carinfo>all=carlistService.getAll();
        all.enqueue(new Callback<Carinfo>() {
            @Override
            public void onResponse(Call<Carinfo> call, Response<Carinfo> response) {
                   Carinfo ca=response.body();
                   String s=ca.getData().get(0).getCarplate();
                   textView.setText(s);
            }

            @Override
            public void onFailure(Call<Carinfo> call, Throwable t) {

            }
        });
    }

    private class QicheGuzhangInfo {
    }
}
